var t = require;
var e = module;
var o = exports;
var _n14,
    i =
        (this && this.__extends) ||
        ((_n14 = function n(t, e) {
            return (_n14 =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) {
                        Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                    }
                })(t, e);
        }),
        function (t, e) {
            function o() {
                this.constructor = t;
            }
            _n14(t, e), (t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o()));
        }),
    s =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var i,
                s = arguments.length,
                r = s < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if (
                "object" == (typeof Reflect === "undefined" ? "undefined" : typeof Reflect) &&
                "function" == typeof Reflect.decorate
            )
                r = Reflect.decorate(t, e, o, n);
            else
                for (var c = t.length - 1; c >= 0; c--) {
                    (i = t[c]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, o, r) : i(e, o)) || r);
                }
            return s > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("Common"),
    c = cc._decorator,
    a = c.ccclass,
    u = c.property,
    l = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (
                (e.game = null),
                (e.leftNativeAd = null),
                (e.leftAdInfo = null),
                (e.leftIcon = null),
                (e.leftLogo = null),
                (e.leftTitle = null),
                (e.leftAdNode = null),
                (e.leftAdLoaded = !1),
                (e.leftAdShow = !1),
                (e.rightButtomNativeAd = null),
                (e.rightButtomAdInfo = null),
                (e.rightButtomIcon = null),
                (e.rightButtomLogo = null),
                (e.rightButtomTitle = null),
                (e.rightButtomDesc = null),
                (e.rightButtomClick = null),
                (e.rightButtomAdNode = null),
                (e.rightButtomAdLoaded = !1),
                (e.rightButtomAdShow = !1),
                (e.centerButtomNativeAd = null),
                (e.centerButtomAdInfo = null),
                (e.centerButtomIcon = null),
                (e.centerButtomLogo = null),
                (e.centerButtomTitle = null),
                (e.centerButtomDesc = null),
                (e.centerButtomClick = null),
                (e.centerButtomAdNode = null),
                (e.centerButtomAdLoaded = !1),
                (e.centerButtomAdShow = !1),
                (e.viewAdNode = null),
                e
            );
        }
        return (
            i(e, t),
            (e.prototype.onLoad = function () {
                var t = this;
                this.leftAdNode.on(
                    cc.Node.EventType.TOUCH_END,
                    function () {
                        t.leftNativeAd.reportAdClick({adId: t.leftAdInfo.adId}),
                            t.scheduleOnce(function () {
                                t.loadLeftAd();
                            }, 2);
                    },
                    this
                ),
                    this.rightButtomAdNode.on(
                        cc.Node.EventType.TOUCH_END,
                        function () {
                            t.rightButtomNativeAd.reportAdClick({adId: t.rightButtomAdInfo.adId}),
                                t.scheduleOnce(function () {
                                    t.loadRightButtomAd();
                                }, 2);
                        },
                        this
                    ),
                    this.centerButtomAdNode.on(
                        cc.Node.EventType.TOUCH_END,
                        function () {
                            t.centerButtomNativeAd.reportAdClick({adId: t.centerButtomAdInfo.adId}),
                                t.scheduleOnce(function () {
                                    t.loadCenterButtomAd();
                                }, 2);
                        },
                        this
                    ),
                    this.viewAdNode.on(
                        cc.Node.EventType.TOUCH_END,
                        function () {
                            t.centerButtomNativeAd.reportAdClick({adId: t.centerButtomAdInfo.adId}),
                                t.scheduleOnce(function () {
                                    t.loadCenterButtomAd();
                                }, 2);
                        },
                        this
                    );
            }),
            (e.prototype.init = function (t) {
                console.log("加载原生广告"),
                    (this.game = t),
                    this.loadLeftAd(),
                    this.loadRightButtomAd(),
                    this.loadCenterButtomAd();
            }),
            (e.prototype.hideLeftAd = function () {
                this.leftAdNode.active = !1;
            }),
            (e.prototype.hideRightButtomAd = function () {
                this.rightButtomAdNode.active = !1;
            }),
            (e.prototype.hideCenterButtomAd = function () {
                this.centerButtomAdNode.active = !1;
            }),
            (e.prototype.showCustomAd = function () {
                this.leftAdLoaded
                    ? ((this.leftAdNode.active = !0),
                      this.leftAdShow || this.leftNativeAd.reportAdShow({adId: this.leftAdInfo.adId}))
                    : (this.leftAdNode.active = !1),
                    this.rightButtomAdLoaded
                        ? ((this.rightButtomAdNode.active = !0),
                          this.rightButtomAdShow ||
                              this.rightButtomNativeAd.reportAdShow({adId: this.rightButtomAdInfo.adId}))
                        : (this.rightButtomAdNode.active = !1);
            }),
            (e.prototype.hideCustomAd = function () {
                (this.leftAdNode.active = !1), (this.rightButtomAdNode.active = !1);
            }),
            (e.prototype.showCustomBigAd = function () {
                this.centerButtomAdLoaded
                    ? ((this.centerButtomAdNode.active = !0),
                      this.centerButtomAdShow ||
                          this.centerButtomNativeAd.reportAdShow({adId: this.centerButtomAdInfo.adId}))
                    : (this.centerButtomAdNode.active = !1);
            }),
            (e.prototype.hideCustomBigAd = function () {
                this.centerButtomAdNode.active = !1;
            }),
            (e.prototype.loadLeftAd = function () {
                var t = this;
                this.leftNativeAd && (this.leftNativeAd.destroy(), (this.leftNativeAd = null)),
                    (this.leftNativeAd = qg.createNativeAd({adUnitId: "494252"})),
                    this.leftNativeAd.onLoad(function (e) {
                        console.log("左边原生广告加载成功", e.adList),
                            (t.leftAdInfo = e.adList[0]),
                            (t.leftTitle.string = t.leftAdInfo.title),
                            r.default.createImage(t.leftAdInfo.logoUrl, t.leftLogo),
                            r.default.createImage(t.leftAdInfo.icon, t.leftIcon),
                            (t.leftAdShow = !1),
                            (t.leftAdLoaded = !0);
                    }),
                    this.leftNativeAd.onError(function (e) {
                        console.log("左边原生广告加载失败", e),
                            (t.leftAdLoaded = !1),
                            t.scheduleOnce(function () {
                                t.loadLeftAd();
                            }, 30);
                    }),
                    this.leftNativeAd.load();
            }),
            (e.prototype.loadRightButtomAd = function () {
                var t = this;
                this.rightButtomNativeAd && (this.rightButtomNativeAd.destroy(), (this.rightButtomNativeAd = null)),
                    (this.rightButtomNativeAd = qg.createNativeAd({adUnitId: "494253"})),
                    this.rightButtomNativeAd.onLoad(function (e) {
                        console.log("Banner1原生广告加载成功", e.adList),
                            (t.rightButtomAdInfo = e.adList[0]),
                            (t.rightButtomTitle.string = t.rightButtomAdInfo.title),
                            (t.rightButtomDesc.string = t.rightButtomAdInfo.desc),
                            (t.rightButtomClick.string = t.rightButtomAdInfo.clickBtnTxt),
                            r.default.createImage(t.rightButtomAdInfo.logoUrl, t.rightButtomLogo),
                            r.default.createImage(t.rightButtomAdInfo.icon, t.rightButtomIcon),
                            (t.rightButtomAdShow = !1),
                            (t.rightButtomAdLoaded = !0);
                    }),
                    this.rightButtomNativeAd.onError(function (e) {
                        console.log("Banner1原生广告加载失败", e),
                            (t.rightButtomAdLoaded = !1),
                            t.scheduleOnce(function () {
                                t.loadRightButtomAd();
                            }, 30);
                    }),
                    this.rightButtomNativeAd.load();
            }),
            (e.prototype.loadCenterButtomAd = function () {
                var t = this;
                this.centerButtomNativeAd && (this.centerButtomNativeAd.destroy(), (this.centerButtomNativeAd = null)),
                    (this.centerButtomNativeAd = qg.createNativeAd({adUnitId: "494271"})),
                    this.centerButtomNativeAd.onLoad(function (e) {
                        console.log("Banner2原生广告加载成功", e.adList),
                            (t.centerButtomAdInfo = e.adList[0]),
                            (t.centerButtomTitle.string = t.centerButtomAdInfo.title),
                            (t.centerButtomDesc.string = t.centerButtomAdInfo.desc),
                            (t.centerButtomClick.string = t.centerButtomAdInfo.clickBtnTxt),
                            r.default.createImage(t.centerButtomAdInfo.logoUrl, t.centerButtomLogo),
                            r.default.createImage(t.centerButtomAdInfo.icon, t.centerButtomIcon),
                            (t.centerButtomAdShow = !1),
                            (t.centerButtomAdLoaded = !0);
                    }),
                    this.centerButtomNativeAd.onError(function (e) {
                        console.log("Banner2原生广告加载失败", e),
                            (t.centerButtomAdLoaded = !1),
                            t.scheduleOnce(function () {
                                t.loadCenterButtomAd();
                            }, 30);
                    }),
                    this.centerButtomNativeAd.load();
            }),
            (e.prototype.start = function () {}),
            s([u(cc.Sprite)], e.prototype, "leftIcon", void 0),
            s([u(cc.Sprite)], e.prototype, "leftLogo", void 0),
            s([u(cc.Label)], e.prototype, "leftTitle", void 0),
            s([u(cc.Node)], e.prototype, "leftAdNode", void 0),
            s([u(cc.Sprite)], e.prototype, "rightButtomIcon", void 0),
            s([u(cc.Sprite)], e.prototype, "rightButtomLogo", void 0),
            s([u(cc.Label)], e.prototype, "rightButtomTitle", void 0),
            s([u(cc.Label)], e.prototype, "rightButtomDesc", void 0),
            s([u(cc.Label)], e.prototype, "rightButtomClick", void 0),
            s([u(cc.Node)], e.prototype, "rightButtomAdNode", void 0),
            s([u(cc.Sprite)], e.prototype, "centerButtomIcon", void 0),
            s([u(cc.Sprite)], e.prototype, "centerButtomLogo", void 0),
            s([u(cc.Label)], e.prototype, "centerButtomTitle", void 0),
            s([u(cc.Label)], e.prototype, "centerButtomDesc", void 0),
            s([u(cc.Label)], e.prototype, "centerButtomClick", void 0),
            s([u(cc.Node)], e.prototype, "centerButtomAdNode", void 0),
            s([u(cc.Node)], e.prototype, "viewAdNode", void 0),
            s([a], e)
        );
    })(cc.Component);
o.default = l;
